package cn.kgc.vue.handlers;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 课工场
 * @date 2023/10/31
 * @description    全局异常处理类
 */
@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(Exception.class)
    public Map  allExceptionHandler(Exception e){

        e.printStackTrace();
        HashMap<String, Object> result = new HashMap<>();
        result.put("code",500);
        result.put("msg","服务器异常，请稍后在试");
        return  result;
    }


}
